home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Atari Compendium
/
The Atari Compendium (Toad Computers) (1994).iso
/
files
/
umich
/
network
/
midi
/
mx2net20.lzh
/
MX2NET20
/
NETWORK.MOD
< prev
Wrap
Text File
|
1990-12-15
|
39KB
|
1,178 lines
(* *)
(* Copyright 1989 fred brooks LogicTek *)
(* *)
(* First Release 12/8/87-FGB *)
(* Added drive config data routines, clean up VBL code, *)
(* Remote time option 12/17/89-FGB *)
(* *)
IMPLEMENTATION MODULE NETWORK ;
(* --------------------------------------------------------------------------
NETWORK : TWO CPU NETWORK FOR TDI Modula-2/ST
--------------------------------------------------------------------------*)
(*$T-,$S-,$A+ *)
FROM SYSTEM IMPORT ADDRESS, ADR, SETREG, CODE, REGISTER ,BYTE ,TSIZE;
FROM BIOS IMPORT BPB ,BConStat ,BConIn, BCosStat, BConOut, Device,
MediaChange,MCState,GetBPB,RWAbs,RW,DriveSet,DriveMap;
FROM XBIOS IMPORT SuperExec,IORec,IORECPTR,IOREC,SerialDevice,
GetDateTime,ScreenPhysicalBase;
FROM GEMDOS IMPORT TermRes,Open,Close,SetDate,SetTime ;
IMPORT GEMDOS;
FROM ASCII IMPORT SYN,STX,SOH,BEL,CR,LF,ESC;
CONST
MaxSeq = 1;
Maxdrives = 31; (* number of disk drives minus 1 *)
recsize = 511;
retry = 5;
MAGIC = 314159;
Memdrive = 31;
chanwait = 3;
debug = FALSE;
trace = FALSE;
TITLE = "MX2NET Version 2.0 Fred Brooks UUCP crash!fgbrooks";
(* Because we dont know what registers the BIOS is using we must use
the following opcodes to save the registers *)
MOVEMDEC = 48E7H ; (* 68000 opcode for MOVEM <regs>,-(A7) *)
MOVEMINC = 4CDFH ; (* 68000 opcode for MOVEM (A7)+,<regs> *)
SAVEREGS = 07FFCH ; (* Registers D1..A5 for DEC *)
RESTREGS = 03FFEH ; (* Registers D1..A5 for INC *)
RTS = 04E75H ; (* 68000 return from subroutine opcode *)
TYPE
(* Procedure types to mimic correct sequence for "C" BIOS routines *)
CBPBProc = PROCEDURE ( CARDINAL ) ;
CMediaChProc = PROCEDURE ( CARDINAL ) ;
CRWAbsProc = PROCEDURE ( CARDINAL, CARDINAL, CARDINAL, ADDRESS, CARDINAL );
MIDIbuffer = ARRAY [0..1023] OF CARDINAL;
SequenceNr = [0..MaxSeq];
message = ARRAY [0..recsize] OF BYTE;
message1 = ARRAY [0..17] OF BYTE;
FrameKind = (ack,data,callreq,callaccp,clearreq,clearconf,
resetreq,diag);
DataKind = (rdmediareq,rdmediaconf,rdbpbreq,rdbpbconf,
rdrwabsreq,rdrwabsconf,memreq,memconf,timereq,timeconf);
evtype = (framearrival,cksumerr,timeout,hostready,reset,nothing);
channel = (none,local,remote);
frame = RECORD
syn : CHAR; (* these are sync chars *)
stx : CHAR; (* for the frames *)
kind : FrameKind;
seq : SequenceNr;
ack : SequenceNr;
cmd : DataKind;
rw : CARDINAL; (* read or write data *)
recno : CARDINAL; (* sector for data*)
d0 : LONGCARD; (* data return variable *)
info : message;
cksum : CARDINAL;
END;
framecptr = POINTER TO framecmd;
framecmd = RECORD
syn : CHAR; (* these are sync chars *)
stx : CHAR; (* for the frames *)
kind : FrameKind;
seq : SequenceNr;
ack : SequenceNr;
cmd : DataKind;
rw : CARDINAL; (* read or write data *)
recno : CARDINAL; (* sector for data*)
d0 : LONGCARD; (* data return variable *)
info : message1;
cksum : CARDINAL;
END;
control = RECORD
magic : LONGCARD;
reset : BOOLEAN;
networkactive : BOOLEAN;
remotedrive : CARDINAL;
drivemap : DriveSet;
nextframetosend : SequenceNr;
frameexpected : SequenceNr;
sendreset : BOOLEAN;
END;
netmap = RECORD
Remote : CARDINAL;
Local : CARDINAL;
Write : BOOLEAN;
END;
frameptr = POINTER TO ARRAY [0..1024] OF BYTE;
VAR
(* BIOS variables : These can only be accessed with the 68000 in supervisor
mode. The Modula-2 language allows you to fix the location of variables *)
HDBPB [0472H] : ADDRESS ; (* hard disk get Bios Parameter Block *)
HDRWAbs [0476H] : ADDRESS ; (* hard disk read/write abs *)
HDMediaCh [047EH] : ADDRESS ; (* hard disk media change *)
EvtCritic [0404H] : ADDRESS ; (* evt_critic *)
DriveBits [04C2H] : SET OF [0..31]; (* disk drives present map *)
flock [043EH] : LONGCARD; (* disk access in progress *)
hz200 [04baH] : LONGCARD; (* 200hz clock counter *)
NetBits : SET OF [0..31];
Dptr : DriveSet; (* save original drive map *)
Mptr : LONGCARD;
charcount,framesize,cksum,recframesize,sndframesize,
SIZEframe,SIZEframecmd : CARDINAL;
networkconnect : BOOLEAN; (* DCD = 1 TRUE *)
gotframe : BOOLEAN;
framebufferfull : BOOLEAN;
cleartosend : BOOLEAN;
readytosend : BOOLEAN;
requesttosend : BOOLEAN;
framewaiting : BOOLEAN;
OK,installed : BOOLEAN;
gotmediach : ARRAY [0..Maxdrives] OF BOOLEAN;
gotbpb : ARRAY [0..Maxdrives] OF BOOLEAN;
networkerror : BOOLEAN;
shortframe : BOOLEAN;
vblLock : BOOLEAN;
rwabsLock : BOOLEAN;
TIMESET : BOOLEAN;
OneTime : BOOLEAN;
ChannelLock : channel;
NetMap : ARRAY [0..Maxdrives] OF netmap;
NetInfo : ARRAY [0..128] OF CHAR;
statptr : POINTER TO stat;
sframe,rframe,SFRAME,RFRAME : frame;
rframeptr : frameptr;
framecmdptr : framecptr;
sframecmdptr : framecptr;
event : evtype;
C : control;
S : stat;
recchar : LONGCARD;
result,i,i1,mediacount,handle : INTEGER;
D0ptr : POINTER TO LONGCARD;
wsector,drvnr,d,R : CARDINAL;
rbuffer : MIDIbuffer;
rbptr,kbdiorec : IORECPTR;
numBytes,sec,min,hour,time,count : LONGCARD ;
status : LONGINT ;
sframeptr : frameptr;
(* The following are saved copies of the BIOS variables so that the real
hard disk routines can be called if a hard disk access is requested. *)
SaveHDBPB : CBPBProc ; (* hard disk get Bios Parameter Block *)
SaveHDRWAbs : CRWAbsProc ; (* hard disk read/write abs *)
SaveHDMediaCh : CMediaChProc ; (* hard disk media change *)
SaveCritic : PROC;
(* NETWORK control *)
NetworkBPB : ARRAY [0..Maxdrives] OF BPB ; (* BIOS Parameter block